s=input()
s1=''
if s.count('(')==s.count(')') and s.count('[')==s.count(']') and s.count('{')==s.count('}') and s.count('<')==s.count('>'):
    for char in s:
        if char =='(':
            s1+=char
        if char ==')':
            if len(s1)>0:
                if s1[len(s1)-1]=='(':
                    s1=s1[:-1]
        if char =='[':
            s1+=char
        if char ==']':
            if len(s1)>0:
                if s1[len(s1)-1]=='[':
                    s1=s1[:-1]
        if char =='{':
            s1+=char
        if char =='}':
            if len(s1)>0:
                if s1[len(s1)-1]=='{':
                    s1=s1[:-1]
        if char =='<':
            s1+=char
        if char =='>':
            if len(s1)>0:
                if s1[len(s1)-1]=='<':
                    s1=s1[:-1]
    if len(s1)==0:
        print('true')
    if len(s1)!=0:
        print('false')
else:
    print('false')
